<template>
  <div class="leftBar">
    <!--  -->
    <el-menu
      :default-active="active"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      text-color="#fff"
      router
      active-text-color="#3386FE"
      @select="handelSelect"
    >
      <div class="logo"></div>
      <el-submenu
        v-for="(item, i) in menuList"
        :key="i + 'menu'"
        :index="item.index"
        v-show="item.child.length != 0"
      >
        <template slot="title">
          <img :src="item.icon" alt="" />
          <span class="el-t">{{ item.name }}</span>
        </template>
        <el-menu-item
          v-for="(res, index) in item.child"
          :key="index + 'item'"
          :index="res.path"
        >
          {{ res.name }}
          <!-- {{
            res.name == "标签制作" && window.sessionStorage["ids"] !== 1
              ? ""
              : res.name
          }} -->
        </el-menu-item>
      </el-submenu>
      <el-menu-item
        v-for="(item, i) in menuList"
        :key="i + 'menuI'"
        :index="item.index"
        v-show="item.child.length == 0"
      >
        <i :class="item.icon"></i>
        <span slot="title">{{ item.name }}</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "leftBar",
  watch: {
    $route: {
      handler: function (val, oldVal) {
        this.active = val.name;
      },
      // 深度观察监听
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      active: "externalData",
      menuList: [
        {
          name: "外部资料录入",
          index: "1",
          icon: require("../assets/icon/left-icon1.png"),
          child: [
            {
              path: "externalData",
              name: "外部数据录入",
            },
            // {
            //   path: "externalEdit",
            //   name: "外部数据编辑",
            // },
            // {
            //   path: "fileMark",
            //   name: "数据置标",
            // },
          ],
        },
        {
          name: "试验数据录入",
          icon: require("../assets/icon/left-icon3.png"),
          index: "2",
          child: [
            {
              path: "syExternalData",
              name: "试验数据录入",
            },
            // { path: "syExternalEdit", name: "试验数据编辑" },
            // { path: "syFileMark", name: "数据置标" },
          ],
        },
        {
          name: "试验数据归档",
          icon: require("../assets/icon/left-icon2.png"),
          index: "3",
          child: [
            {
              path: "archivingManag",
              name: "归档任务管理",
            },
            // { path: "archiveInfo", name: "归档信息管理" },
          ],
        },
        {
          name: "置标管理",
          icon: require("../assets/icon/left-icon5.png"),
          index: "4",
          child: [
            {
              path: "markCreation",
              name: "标签制作",
            },
            {
              path: "markCreationeExamine",
              name: "标签审核",
            },
            {
              path: "fileMark",
              name: "数据置标",
            },
            {
              path: "syFileMark",
              name: "数据置标审核",
            },
          ],
        },
        {
          name: "标准规范管理",
          icon: require("../assets/icon/left-icon5.png"),
          index: "5",
          child: [
            {
              path: "specification",
              name: "标准规范管理",
            },
          ],
        },
        {
          name: "资源库管理",
          icon: require("../assets/icon/left-icon5.png"),
          index: "6",
          child: [
            {
              path: "Integration",
              name: "整编库管理",
            },
            {
              path: "IntegrationType",
              name: "整编库类型管理",
            },
            {
              path: "IntegrationSh",
              name: "整编库审核",
            },
            {
              path: "fileIntegration",
              name: "文件整编",
            },
            {
              path: "fileIntegrationSh",
              name: "文件整编审核",
            },
            {
              path: "IntegrationLibrary",
              name: "整编库资源展示",
            },
          ],
        },
        {
          name: "内容识别",
          icon: require("../assets/icon/left-icon5.png"),
          index: "7",
          child: [
            {
              path: "fileType",
              name: "文件类型",
            },
            {
              path: "fileUpSh",
              name: "文件审核",
            },
            {
              path: "fileSearch",
              name: "文本展示",
            },
          ],
        },
      ],
    };
  },
  mounted() {},
  methods: {
    handelSelect(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleOpen(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
  },
};
</script>
<style>
.el-submenu__title {
  background-color: #1f2d3c;
  border-bottom: 1px solid #132232;
}
.el-submenu__title:hover {
  background-color: #2f3c49;
}
.el-submenu.is-active .el-submenu__title {
  border-bottom-color: #132232;
}
</style>
<style scoped lang="scss">
.leftBar {
  width: 270px;
  height: 100%;
  float: left;
  overflow: hidden;
  background: #132232;
  box-shadow: 5px 3px 6px rgba(0, 0, 0, 0.25);
  opacity: 1;
  border-radius: 0px;
  min-height: 100vh;
  .el-menu {
    background-color: #132232;
    height: 100%;
    // .el-submenu{
    .el-menu-item,
    .el-t {
      font-size: 18px;
      font-family: Source Han Sans CN-Normal, Source Han Sans CN;
      font-weight: 400;
      color: rgba(255, 255, 255, 0.9);
    }
    .el-submenu__title i,
    .el-menu-item i {
      color: #fff;
    }
    .el-menu-item {
      background-color: #1f2d3c;
      border-bottom: 1px solid #132232;
    }
    .is-active {
      color: #3386fe;
      background-color: #132232;
    }

    // }
  }
  .logo {
    width: 210px;
    height: 60px;
    background: url("../assets/logo.png") no-repeat;
    background-size: cover;
    margin: 10px 15px;
  }
}
</style>
